package com.monkeybrother.thread.atomic;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;

public class ThreadJoinTest {
    private static AtomicInteger num = new AtomicInteger(0);
    public static void main(String[] args) throws IOException, InterruptedException {
//        Thread thread = new Thread(() -> {
//            System.out.println("子线程开始启动");
//            try {
//                TimeUnit.SECONDS.sleep(3);
//                System.out.println("子线程执行任务结束");
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        });
//        thread.start();
//        System.out.println("主线程执行结束");
        System.out.printf("start");
        ServerSocket serverSocket = new ServerSocket(9884);
        Socket socket = serverSocket.accept();
        OutputStream outputStream = socket.getOutputStream();
        InputStream inputStream = socket.getInputStream();
        while (true) {
            TimeUnit.SECONDS.sleep(5);
//            outputStream.write("0123000000000000EEBBBFE8B1AAE8B68A9A0D0A023a0618320001730D0A0123000000000000EEBBBFE8B1AAE8B68A9A0D0A023a0618320001730D0A".getBytes(StandardCharsets.UTF_8));
            outputStream.write("01230000000000007b2274797065223a202230222c22646973636f756e74223a202231222c22757365724964223a20223133363237333438353734333632313533343536227d0D0A".getBytes(StandardCharsets.UTF_8));

        }



    }
}
